//
//  LogOutView.m
//  shanHaiHuiApp
//
//  Created by DS on 2018/9/27.
//  Copyright © 2018年 徐双. All rights reserved.
//

#import "LogOutView.h"

@interface LogOutView()

Copy void(^selectedHandle)(NSString *str);


Strong UIImageView * bgView;
Strong UILabel * logotLabel;





@end

@implementation LogOutView

#pragma mark --- Action

- (void)logoOutClick{
    
    if (_getLogoutClick) {
        _getLogoutClick(self);
    }
    
    
}



#pragma mark --- Init

- (instancetype)initWithFrame:(CGRect)frame selectedHandle:(void (^)(NSString *))selectedHandle{
    if (self = [super initWithFrame:frame]) {
        self.alpha = 0;
        UIButton *backButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        _selectedHandle = selectedHandle;
        backButton.backgroundColor = [UIColor blackColor];
        backButton.alpha = .6;
        backButton.titleLabel.font = DEF_FontSize_13;
        [backButton addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:backButton];
        
        
        _bgView = [[UIImageView alloc] init];
        _bgView.frame = CGRectMake(SCREEN_WIDTH - UNIT_WIDTH(120), height64, 100, 40);
        _bgView.image = [UIImage imageNamed:@"yaoshidianping-spdy"];
        _bgView.userInteractionEnabled = YES;
        
         [self addSubview:_bgView];
        
        
        _logotLabel = [UILabel addLableFont:16 WithColor:getColor(@"4E4E4E")];
        _logotLabel.text = @"退出登录";
        _logotLabel.textAlignment = NSTextAlignmentCenter;
        _logotLabel.userInteractionEnabled = YES;
        UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(logoOutClick)];
        [_logotLabel addGestureRecognizer:tap];
        
        [_bgView addSubview:_logotLabel];
        
        [self.logotLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(0);
            make.left.mas_equalTo(0);
            make.right.mas_equalTo(0);
            make.bottom.mas_equalTo(0);
        }];
        
      
       
        
        
    }
    return self;
}




#pragma mark -- 显示还是不显示
//出现
-(void)show{
    [[UIApplication sharedApplication].delegate.window addSubview:self];
    [UIView animateWithDuration:.15 animations:^{
        self.alpha = 1;
    }];
}

//消失
-(void)dismiss{
    [UIView animateWithDuration:.15 animations:^{
        self.alpha = 0 ;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
}

@end
